//147
class Solution {
    public ListNode insertionSortList(ListNode head) {
        if(head == null){
            return null;
        }
        ListNode newH = new ListNode();
        newH.next = head;
        ListNode cur = head;
        ListNode curNext = cur.next;
        while(curNext != null){
            if(cur.val > curNext.val){
                ListNode prev = newH;
                while(prev.next.val <= curNext.val){
                    prev = prev.next;
                }
                cur.next = curNext.next;
                curNext.next = prev.next;
                prev.next = curNext;
            }else{
                cur = cur.next;
            }
            curNext = cur.next;
        }
        return newH.next;
    }
}
public class Test {
}
